package com.ruoyi.course.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.course.mapper.CourseFloorMapper;
import com.ruoyi.course.domain.CourseFloor;
import com.ruoyi.course.service.ICourseFloorService;

/**
 * 楼栋Service业务层处理
 *
 * @author mac
 * @date 2023-03-11
 */
@Service public class CourseFloorServiceImpl implements ICourseFloorService {
    @Autowired private CourseFloorMapper courseFloorMapper;

    /**
     * 查询楼栋
     *
     * @param id 楼栋主键
     * @return 楼栋
     */
    @Override public CourseFloor selectCourseFloorById(Long id) {
        return courseFloorMapper.selectCourseFloorById(id);
    }

    /**
     * 查询楼栋列表
     *
     * @param courseFloor 楼栋
     * @return 楼栋
     */
    @Override public List<CourseFloor> selectCourseFloorList(CourseFloor courseFloor) {
        return courseFloorMapper.selectCourseFloorList(courseFloor);
    }

    /**
     * 新增楼栋
     *
     * @param courseFloor 楼栋
     * @return 结果
     */
    @Override public int insertCourseFloor(CourseFloor courseFloor) {
        CourseFloor floor = courseFloorMapper.selectCourseFloorByName(courseFloor.getFloorName());
        if (floor != null) {
            throw new RuntimeException("该楼层已存在！");
        }
        return courseFloorMapper.insertCourseFloor(courseFloor);
    }

    /**
     * 修改楼栋
     *
     * @param courseFloor 楼栋
     * @return 结果
     */
    @Override public int updateCourseFloor(CourseFloor courseFloor) {
        return courseFloorMapper.updateCourseFloor(courseFloor);
    }

    /**
     * 批量删除楼栋
     *
     * @param ids 需要删除的楼栋主键
     * @return 结果
     */
    @Override public int deleteCourseFloorByIds(Long[] ids) {
        return courseFloorMapper.deleteCourseFloorByIds(ids);
    }

    /**
     * 删除楼栋信息
     *
     * @param id 楼栋主键
     * @return 结果
     */
    @Override public int deleteCourseFloorById(Long id) {
        return courseFloorMapper.deleteCourseFloorById(id);
    }
}
